package com.hongyue.shiJian1;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter dt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println("请输入第一个日期");
        String a = sc.nextLine();
        System.out.println("请输入第二个日期");
        String b = sc.nextLine();
        LocalDateTime a1 = LocalDateTime.parse(a, dt);
        LocalDateTime b1 = LocalDateTime.parse(b, dt);
        Duration a2 = Duration.between(a1, now);
        long a3 = a2.toHours();
        Duration b2 = Duration.between(b1, now);
        long b3 = b2.toHours();
        if (a3 >= 0 && b3 >= 0) {
            if (a3 > b3) {
                System.out.println("第一个输入的时间大");
            } else if (a3 < b3) {
                System.out.println("第二个输入的时间大");
            } else {
                System.out.println("两次输入的时间相同");
            }
        } else {
            System.out.println("您输入的时间不对");
        }
    }
}
